package com.jacken.springcloudseatabank01.controller;

import com.jacken.springcloudseatabank01.entity.basic.Result;
import com.jacken.springcloudseatabank01.service.IAccountService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author wangqiang
 * @version 1.0
 * @date 2020/10/8 10:13
 */
@RestController
@RequestMapping
public class TransferController {


    @Resource
    private  IAccountService accountService;


    /**
     * 转账 发起方
     *
     * @param accountNo      自己的账户
     * @param otherAccountNo 他人的账户
     * @param accountBalance 金额
     * @return result
     */
    @GetMapping("/transfer")
    public Result transfer(@RequestParam("accountNo") String accountNo,@RequestParam("otherAccountNo") String otherAccountNo,@RequestParam("accountBalance") Double accountBalance) {
        accountService.updateAccountBalance(accountNo, otherAccountNo, accountBalance);
        return Result.success();
    }
}
